
<h1><span class="yiyi-st" id="yiyi-12">numpy.fft.rfft</span></h1>
        <blockquote>
        <p>原文：<a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.fft.rfft.html">https://docs.scipy.org/doc/numpy/reference/generated/numpy.fft.rfft.html</a></p>
        <p>译者：<a href="https://github.com/wizardforcel">飞龙</a> <a href="http://usyiyi.cn/">UsyiyiCN</a></p>
        <p>校对：（虚位以待）</p>
        </blockquote>
    
<dl class="function">
<dt id="numpy.fft.rfft"><span class="yiyi-st" id="yiyi-13"> <code class="descclassname">numpy.fft.</code><code class="descname">rfft</code><span class="sig-paren">(</span><em>a</em>, <em>n=None</em>, <em>axis=-1</em>, <em>norm=None</em><span class="sig-paren">)</span><a class="reference external" href="http://github.com/numpy/numpy/blob/v1.11.3/numpy/fft/fftpack.py#L287-L370"><span class="viewcode-link">[source]</span></a></span></dt>
<dd><p><span class="yiyi-st" id="yiyi-14">计算实数输入的一维离散傅里叶变换。</span></p>
<p><span class="yiyi-st" id="yiyi-15">该函数通过称为快速傅里叶变换（FFT）的有效算法来计算实值数组的一维<em>n</em>点离散傅里叶变换（DFT）。</span></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name">
<col class="field-body">
<tbody valign="top">
<tr class="field-odd field"><th class="field-name"><span class="yiyi-st" id="yiyi-16">参数：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-17"><strong>a</strong>：array_like</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-18">输入数组</span></p>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-19"><strong>n</strong>：int，可选</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-20">要使用的输入中沿变换轴的点数。</span><span class="yiyi-st" id="yiyi-21">如果<em class="xref py py-obj">n</em>小于输入的长度，则输入被裁剪。</span><span class="yiyi-st" id="yiyi-22">如果它较大，输入用零填充。</span><span class="yiyi-st" id="yiyi-23">如果未给出<em class="xref py py-obj">n</em>，则使用沿由<em class="xref py py-obj">轴</em>指定的轴的输入长度。</span></p>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-24"><strong>axis</strong>：int，可选</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-25">用于计算FFT的轴。</span><span class="yiyi-st" id="yiyi-26">如果未给出，则使用最后一个轴。</span></p>
</div></blockquote>
<p><span class="yiyi-st" id="yiyi-27"><strong>norm</strong>：{None，“ortho”}，可选</span></p>
<blockquote>
<div><div class="versionadded">
<p><span class="yiyi-st" id="yiyi-28"><span class="versionmodified">版本1.10.0中的新功能。</span></span></p>
</div>
<p><span class="yiyi-st" id="yiyi-29">规范化模式（参见<a class="reference internal" href="../routines.fft.html#module-numpy.fft" title="numpy.fft"><code class="xref py py-obj docutils literal"><span class="pre">numpy.fft</span></code></a>）。</span><span class="yiyi-st" id="yiyi-30">默认值为None。</span></p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name"><span class="yiyi-st" id="yiyi-31">返回：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-32"><strong>out</strong>：complex ndarray</span></p>
<blockquote>
<div><p><span class="yiyi-st" id="yiyi-33">未指定沿<em class="xref py py-obj">轴</em>指示的轴变换的截断或零填充输入，如果<em class="xref py py-obj">轴</em>指定最后一个输入。</span><span class="yiyi-st" id="yiyi-34">If <em class="xref py py-obj">n</em> is even, the length of the transformed axis is <code class="docutils literal"><span class="pre">(n/2)+1</span></code>. </span><span class="yiyi-st" id="yiyi-35">如果<em class="xref py py-obj">n</em>是奇数，则长度为<code class="docutils literal"><span class="pre">(n+1)/2</span></code>。</span></p>
</div></blockquote>
</td>
</tr>
<tr class="field-odd field"><th class="field-name"><span class="yiyi-st" id="yiyi-36">上升：</span></th><td class="field-body"><p class="first"><span class="yiyi-st" id="yiyi-37"><strong>IndexError</strong></span></p>
<blockquote class="last">
<div><p><span class="yiyi-st" id="yiyi-38">如果<em class="xref py py-obj">axis</em>大于<em class="xref py py-obj">a</em>的最后一个轴。</span></p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title"><span class="yiyi-st" id="yiyi-39">也可以看看</span></p>
<dl class="last docutils">
<dt><span class="yiyi-st" id="yiyi-40"><a class="reference internal" href="../routines.fft.html#module-numpy.fft" title="numpy.fft"><code class="xref py py-obj docutils literal"><span class="pre">numpy.fft</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-41">用于定义所使用的DFT和约定。</span></dd>
<dt><span class="yiyi-st" id="yiyi-42"><a class="reference internal" href="numpy.fft.irfft.html#numpy.fft.irfft" title="numpy.fft.irfft"><code class="xref py py-obj docutils literal"><span class="pre">irfft</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-43"><a class="reference internal" href="#numpy.fft.rfft" title="numpy.fft.rfft"><code class="xref py py-obj docutils literal"><span class="pre">rfft</span></code></a>的逆。</span></dd>
<dt><span class="yiyi-st" id="yiyi-44"><a class="reference internal" href="numpy.fft.fft.html#numpy.fft.fft" title="numpy.fft.fft"><code class="xref py py-obj docutils literal"><span class="pre">fft</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-45">一维（复数）输入的一维FFT。</span></dd>
<dt><span class="yiyi-st" id="yiyi-46"><a class="reference internal" href="numpy.fft.fftn.html#numpy.fft.fftn" title="numpy.fft.fftn"><code class="xref py py-obj docutils literal"><span class="pre">fftn</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-47"><em>n</em>维FFT。</span></dd>
<dt><span class="yiyi-st" id="yiyi-48"><a class="reference internal" href="numpy.fft.rfftn.html#numpy.fft.rfftn" title="numpy.fft.rfftn"><code class="xref py py-obj docutils literal"><span class="pre">rfftn</span></code></a></span></dt>
<dd><span class="yiyi-st" id="yiyi-49">实输入的<em>n</em>维FFT。</span></dd>
</dl>
</div>
<p class="rubric"><span class="yiyi-st" id="yiyi-50">笔记</span></p>
<p><span class="yiyi-st" id="yiyi-51">当为纯实数输入计算DFT时，输出是埃尔米特对称的，即负频率项仅是相应正频率项的复共轭，因此负频率项是多余的。</span><span class="yiyi-st" id="yiyi-52">该函数不计算负频率项，因此输出的变换轴的长度为<code class="docutils literal"><span class="pre">n // 2</span> <span class="pre">+</span> <span class="pre">1 </span></code>。</span></p>
<p><span class="yiyi-st" id="yiyi-53">当<code class="docutils literal"><span class="pre">A</span> <span class="pre">=</span> <span class="pre">rfft（a）</span></code>且fs是采样频率时，<code class="docutils literal"><span class="pre">A[0]</span></code></span></p>
<p><span class="yiyi-st" id="yiyi-54">如果<em class="xref py py-obj">n</em>是偶数，则<code class="docutils literal"><span class="pre">A[-1]</span></code>包含表示正和负奈奎斯特频率（+ fs / 2和-fs / 2）的项，纯粹真实。</span><span class="yiyi-st" id="yiyi-55">如果<em class="xref py py-obj">n</em>是奇数，则在fs / 2处没有项； <code class="docutils literal"><span class="pre">A[-1]</span></code>包含最大的正频率（fs / 2 *（n-1）/ n），并且在一般情况下是复数。</span></p>
<p><span class="yiyi-st" id="yiyi-56">如果输入<em class="xref py py-obj">a</em>包含虚部，它将被静默丢弃。</span></p>
<p class="rubric"><span class="yiyi-st" id="yiyi-57">例子</span></p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">fft</span><span class="o">.</span><span class="n">fft</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">])</span>
<span class="go">array([ 1.+0.j,  0.-1.j, -1.+0.j,  0.+1.j])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">np</span><span class="o">.</span><span class="n">fft</span><span class="o">.</span><span class="n">rfft</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">])</span>
<span class="go">array([ 1.+0.j,  0.-1.j, -1.+0.j])</span>
</pre></div>
</div>
<p><span class="yiyi-st" id="yiyi-58">请注意，对于实际输入，<a class="reference internal" href="numpy.fft.fft.html#numpy.fft.fft" title="numpy.fft.fft"><code class="xref py py-obj docutils literal"><span class="pre">fft</span></code></a>输出的最后一个元素是第二个元素的复共轭。</span><span class="yiyi-st" id="yiyi-59">对于<a class="reference internal" href="#numpy.fft.rfft" title="numpy.fft.rfft"><code class="xref py py-obj docutils literal"><span class="pre">rfft</span></code></a>，该对称性被用于仅计算非负频率项。</span></p>
</dd></dl>
